"""
RedFlag-TC000034   比例功能检查
切换比例场景
多次切换比例拍摄场景
"""
__author__ = "ldm"

import sys
import os
# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()

log("------------------------------切换比例场景-----------------------------")
"""
进入相机拍摄
点击展开按钮
获取当前比例
点击比例
获取切换后的比例
断言
判断当前比例
"""
shooter.enter_photograph()
shooter.click_element(shooting_page_expand)
old_size = poco("cn.migu.video.clip.walle:id/clip_rc_mixview").get_size()
shooter.click_element(shooting_page_proportion)
new_size = poco("cn.migu.video.clip.walle:id/clip_rc_mixview").get_size()
shooter.assert_texts_not_equal(old_size, new_size, "断言失败,两个比例的值一样,切换比例失败")
log("当前比例4:3" if old_size[1]>new_size[1] else "当前比例9:16")


log("----------------------------多次切换比例场景-----------------------------")
"""
多次切换比例
断言是否出现崩溃等问题
"""
shooter.multiple_dense_clicks(shooting_page_proportion,20,0.5)
shooter.assert_element_exists(shoot_page_video, "断言失败,不能获取元素信息,可能出现崩溃情况")

# 关闭应用
stop_app(UGC_package_name)